package com.cacho.s2b.lesson.learn;

import com.cacho.s2b.lesson.utils.Constants;

import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;

public class LearnMessageDigest {
    private static final String MD5 = Constants.MD5;
    public static void main(String[] args){
        System.out.println(Md5("CACHO"));
    }

    public static String Md5(String blankText){
        try {
            MessageDigest md = MessageDigest.getInstance(MD5);
            md.update(blankText.getBytes(StandardCharsets.UTF_8)); //byte
            System.out.println(LearnBase64.encode(md.digest()).getClass());
            return LearnBase64.encode(md.digest()); //pt1fMFE6cPkCiSpVv3fy7w==
        } catch (Exception ex){
            throw new RuntimeException(ex);
        }

    }

}
